﻿Imports Entities
Public Class PagosVentaDAL
    Public Shared Function Create(ByVal zobject As pagosventa) As pagosventa
        Try
            Using bd As New gas_gasdesuvecinoEntities
                bd.PagosVenta.Add(zobject)
                bd.SaveChanges()
                Return zobject
            End Using
        Catch ex As Exception
            Return Nothing
        End Try
    End Function

    Public Shared Function ListByVentaId(ByVal zVentaId As Long) As List(Of pagosventa)
        Try
            Using bd As New gas_gasdesuvecinoEntities
                Dim query = From rec In bd.pagosventa
                            Where rec.VENTA = zVentaId
                            Select rec

                Return query.ToList
            End Using
        Catch ex As Exception
            Return Nothing
        End Try
    End Function

    Public Shared Function SearchByPagoId(ByVal zPagoid As Long) As pagosventa
        Try
            Using bd As New gas_gasdesuvecinoEntities
                Return bd.PagosVenta.Find(zPagoid)
            End Using

        Catch ex As Exception
            Return Nothing
        End Try
    End Function
    Public Shared Function Delete(ByVal zPago As pagosventa) As Boolean
        Try
            Using bd As New gas_gasdesuvecinoEntities
                bd.PagosVenta.Remove(zPago)
                bd.SaveChanges()
                Return True
            End Using
        Catch ex As Exception
            Return Nothing
        End Try
    End Function
End Class
